package com.example.ttkl.presenter;

import com.example.ttkl.Base.BasePresenter;
import com.example.ttkl.Base.CommonSubScriBer;
import com.example.ttkl.bean.GiteeCommitsBean;
import com.example.ttkl.interfaces.IHome;
import com.example.ttkl.model.HttpManager;
import com.example.ttkl.util.RxUtils;

public class HomePresenter extends BasePresenter<IHome.MainView> implements IHome.MainPersenter {

    @Override
    public void getCommits() {
        addSubscribe(HttpManager
                .getInstance()
                .getHomeApi()
                .getCommites()
                .compose(RxUtils.<GiteeCommitsBean>rxScheduler())
                .subscribeWith(new CommonSubScriBer<GiteeCommitsBean>(mView) {
                    @Override
                    public void onNext(GiteeCommitsBean homeBean) {
                        if (mView != null) {
                            mView.getCommits(homeBean);
                        }
                    }
                }));
    }
}
